import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";

/**
 *
 * @date: 2019-10-16
 */
import intl from 'utils/intl';
import { CPAAS_PLATFORM } from 'utils/config';
import { getCurrentOrganizationId, isTenantRoleLevel } from 'utils/utils';
import uuid from 'uuid/v4';
var organizationId = getCurrentOrganizationId();
var listDS = {
  primaryKey: uuid(),
  dataKey: 'content',
  selection: false,
  autoQuery: true,
  queryFields: [!isTenantRoleLevel() && {
    name: 'tenantId',
    type: 'object',
    label: intl.get('cpfm.online.model.online.tenantName').d('当前租户'),
    lovCode: 'CPFM.TENANT',
    noCache: true
  }].filter(Boolean),
  fields: [{
    name: 'loginName',
    type: 'string',
    label: intl.get('cpfm.online.model.online.loginName').d('登录名')
  }, {
    name: 'tenantName',
    type: 'string',
    label: intl.get('cpfm.online.model.online.tenantName').d('当前租户')
  }, {
    name: 'organizationName',
    type: 'string',
    label: intl.get('cpfm.online.model.online.organizationName').d('所属租户')
  }, {
    name: 'loginDate',
    type: 'dateTime',
    label: intl.get('cpfm.online.model.online.loginDate').d('登陆时间')
  }, {
    name: 'loginIp',
    type: 'string',
    label: intl.get('cpfm.online.model.online.loginIp').d('登录地址')
  }, {
    name: 'phone',
    type: 'string',
    label: intl.get('cpfm.online.model.online.phone').d('电话')
  }, {
    name: 'email',
    type: 'string',
    label: intl.get('cpfm.online.model.online.email').d('邮箱')
  }],
  transport: {
    read: function read(config) {
      var data = config.data;
      var tenantId = data.tenantId;
      return _objectSpread(_objectSpread({}, config), {}, {
        method: 'get',
        url: "".concat(CPAAS_PLATFORM, "/v1").concat(isTenantRoleLevel() ? "/".concat(organizationId, "/") : "/", "online-users"),
        data: _objectSpread(_objectSpread({}, data), {}, {
          tenantId: tenantId && tenantId.tenantId
        })
      });
    }
  }
};
export { listDS };